<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
        content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
    <style>
        .layui-btn-container .layui-btn {
            margin-left: 10px;
        }
        /* 按钮容器固定在底部 */
        .layui-btn-container {
            position: absolute;
            bottom: 20px;
            left: 20px;
            right: 20px;
            text-align: right;
        }
        .layui-btn-container .layui-btn {
            margin-left: 10px;
        }

        .layui-form-item {
            margin-bottom: 20px;
        }

        /* 给form表单加一个内边距，避免按钮和内容重叠 */
        .layui-form {
            position: relative;
            padding-bottom: 60px; /* 为按钮预留空间 */
            min-height: 350px; /* 确保足够空间显示 */
        }
    </style>
</head>



<body layadmin-themealias="default">
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-form" wid100="" lay-filter="">
                    <div class="layui-form-item">
                        <select name="sources" class="layui-select" lay-verify="required" lay-search="">
                            <option value="">请选择或搜索关键词</option>
                            {volist name="sources" id="vo"}
                            <option value="{$vo->source_key}">{$vo->source_name} | {$vo->source_key}</option>
                            {/volist}
                        </select>
                    </div>
                                                
                    <div class="layui-btn-container">
                        <button class="layui-btn layui-btn-primary" id="close">取消</button>
                        <button class="layui-btn" lay-submit="" lay-filter="source-config-add">确认新增</button>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="/layuiadmin/layui/layui.js"></script>
    <script>
        layui.config({
            base: '/layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'form', 'admin', 'regsource'], function () {
            var $ = layui.$
                , form = layui.form
                , admin = layui.admin;
            var index = parent.layer.getFrameIndex(window.name);

            $('#close').on("click", function () {
                parent.layer.close(index);
            });

            form.on('submit(source-config-add)', function (data) {
                var selectedSource = data.field.sources; // 获取选中参数的值
                window.parent.postMessage({ type: 'source-selected', source: selectedSource }, '*'); // 通知父页面
                parent.layer.close(index);
                return false; // 阻止表单默认提交
            });
        });
    </script>
</body>

</html>
